const express = require('express');
const mongoose =require('mongoose')
// connect only dataBase
// const db = require('../config/mongoose')
// let kittyCat;
// async function main () {
//     kittyCat= await db();
// }
// main()

// connect more dataBase
const result = require('../config/mongoose_connect_more')
let admin, cat;
function main(){
    admin = result.admin
    cat = result.cat
}
main()


const app = express()

const Routers = express.Router()

Routers.get('/',(req,res)=>{
    res.send('hello world')
})
app.get('/admin',async (req,res)=>{
    let adminData = await admin.find()
    res.send(JSON.stringify(adminData))
})
app.get('/',async (req,res)=>{
    let catData = await cat.find()
    res.send(JSON.stringify(catData))
})

app.use('/api',Routers)

app.listen(3001,function(){
    console.log('connect success localhsot: http://localhost:3001')
})